<template>
	<view class="page">
		<backTop v-if='toTop'></backTop>
		<status-bar title="我的社区"></status-bar>
		<view class="list" v-if='list && list.length > 0'>
			<view class="item" :style="{'--color': color}" v-for="(item,i) in list" :key='i' @click="toUrl('order?vid='+item.v_id)">
				<view class="flex-box align-center">
					<image :src="item.v_headimg?item.v_headimg:staticUrl+'/images/jh_up/head.jpg'" mode="aspectFill" class="avatar"></image>
					<text class="name">{{ item.name }}</text>
					<text class="tel flex">({{ item.phone }})</text>
					<text class="myfans">会员数：{{ item.member }}</text>
				</view>
				<view class="address">{{ item.neighbourhood }}</view>
				<view class="address">{{ item.city }}</view>
				<view class="flex-box count-box align-center">
					<view>订单量:{{ item.orders }}</view>
					<view>总金额:{{ item.payment }}</view>
					<view>总佣金:{{ item.money }}</view>
				</view>
			</view>
		</view>
		<empty type='1' msg='这里空空如也 ~' cat='4' v-if='noData'></empty>
		<view class="DiLine" v-if='list && list.length > 6'>------我也是有底线的------</view>
	</view>
</template>

<script>
	let that
	export default {
		data() {
			return {
				toTop: false,
				color: getApp().globalData.color,
				staticUrl: this.staticUrl,
				imgUrl: this.imgUrl,

				list: [],
				noData: false
			}
		},
		onShow() {
			that = this
			that.get_my_station()
		},
		methods: {
			get_my_station: function() {
				that.$http.get({
					url: '/singleSaleApi/my_station',
					data: {
						share_v_id: uni.getStorageSync('vid')
					}
				}).then(res => {
					if (res.code == 100) {
						if(res.data && res.data.masters){
							that.list = res.data.masters
						}
						if(!that.list || that.list.length < 1){
							that.noData = true
						}
					} else {
						uni.showToast({
							icon: "none",
							title: res.msg,
							duration: 2000
						})
					}
				})
			}
		},
		onPageScroll(e) {
			if (e.scrollTop > 250) {
				this.toTop = true;
			} else {
				this.toTop = false
			}
		},
		onShareAppMessage() {
			let shareData = uni.getStorageSync('shareData');
			let vid = uni.getStorageSync('vid')
			return {
				title: shareData.title,
				desc: shareData.desc,
				path: '/pages/index/index?share_v_id=' + vid,
				imageUrl: shareData.imageUrl
			}
		},
	}
</script>

<style lang="scss">
.page{
	background-color: #F5F5F5;
	.list{
		padding: 20rpx;
		text,view{
			color: #333333;
			font-size: 28rpx;
		}
		.item{
			background-color: #FFFFFF;
			border-radius: 8rpx;
			padding-top: 24rpx;
			position: relative;
			margin-bottom: 20rpx;
			&::before{
				content: '';
				position: absolute;
				width: 16rpx;
				height: 16rpx;
				left: -8rpx;
				top: 10rpx;
				border-radius: 4rpx;
				background-color: var(--color);
			}
			.avatar{
				width: 32rpx;
				height: 32rpx;
				border-radius: 50%;
				margin-right: 16rpx;
				margin-left: 24rpx;
			}
			.name{
				font-weight: bold;
				margin-right: 10rpx;
			}
			.tel{
				color: #999999;
			}
			.myfans{
				padding-right: 24rpx;
				font-size: 24rpx;
				font-weight: bold;
			}
			.address{
				margin-top: 14rpx;
				padding: 0 24rpx;
				color: #666666;
			}
			.count-box{
				margin-top: 20rpx;
				border-top: 1px solid #EEEEEE;
				justify-content: space-between;
				text-align: center;
				height: 84rpx;
				padding: 0 24rpx;
				view{
					font-size: 24rpx;
					font-weight: bold;
				}
			}
		}
	}
}
</style>
